﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;

namespace ProgNetComponents.Classes
{
    /// <summary>
    /// FakeSite class. Implements ISite
    /// </summary>
    public class FakeSite : ISite
    {
        /// <summary>
        /// Gets Owner
        /// </summary>
        public Component Owner { get; private set; }
        /// <summary>
        /// Gets ParentSite
        /// </summary>
        public ISite ParentSite { get; private set; }

        /// <summary>
        /// Creates FakeSite instance
        /// </summary>
        /// <param name="owner">Owner</param>
        /// <param name="parentSite">ParentSite</param>
        public FakeSite(Component owner, ISite parentSite)
        {
            this.Owner = owner;
            this.ParentSite = parentSite;
        }
        /// <summary>
        /// Gets owner component
        /// </summary>
        public IComponent Component
        {
            get { return Owner; }
        }
        /// <summary>
        /// Gets ParentSite Container
        /// </summary>
        public IContainer Container
        {
            get
            {
                if (ParentSite != null)
                    return ParentSite.Container;
                return null;
            }
        }
        /// <summary>
        /// Gets if ParentSite is in DesignMode
        /// </summary>
        public bool DesignMode
        {
            get
            {
                if (ParentSite != null)
                    return ParentSite.DesignMode;
                return false;
            }
        }
        /// <summary>
        /// Gets or sets Name
        /// </summary>
        public string Name
        {
            get;
            set;
        }
        /// <summary>
        /// Gets Service using ParentSite
        /// </summary>
        /// <param name="serviceType"></param>
        /// <returns></returns>
        public object GetService(Type serviceType)
        {
            if (ParentSite != null)
                return ParentSite.GetService(serviceType);
            return null;
        }
    }
}
